'use strict';

define(['controllers'], function (controllers) {
    controllers.common.controller('PagedController', ['$scope', function ($scope) {
        $scope.index = function (i) {
            $scope.query(i);
        };
        $scope.prev = function () {
            if ($scope.pageNo > 1) {
                $scope.query($scope.pageNo - 1);
            }
        };
        $scope.next = function () {
            if ($scope.pageNo < $scope.paged.totalPage) {
                $scope.query($scope.pageNo + 1);
            }
        };
        $scope.range = function (start, end, step) {
            step = (step === undefined) ? 1 : step;
            var input = [];
            for (var i = start; i <= end; i += step) {
                input.push(i);
            }
            return input;
        };
        $scope.max = function (i, j) {
            return i > j ? i : j;
        };
        $scope.min = function (i, j) {
            return i < j ? i : j;
        };
    }]);
});